<?php

namespace App\Modules\Manage\Model;

use Illuminate\Database\Eloquent\Model;
use Cache;

class NavModel extends Model
{
    
    protected $table = 'nav';
    protected $primaryKey = 'id';

    protected $fillable = [
        'id','title','link_url','style','sort','is_new_window','is_show','created_at','updated_at'
    ];

    public $timestamps = false;


    static function getNavList()
    {
        if(Cache::has('navList'))
        {
            $navList =  Cache::get('navList');
        }
        else
        {
            $navList = self::where('is_show',1)->orderBy('sort','ASC')->get();
            if(empty($navList))
            {
                $navList = $navList->toArray();
                Cache::put('navList', $navList, 60*24);
            }
        }

        return $navList;
    }

}
